简单的If和Else:
1 | a = 4 |
这个If语句和下面的Or and 是一样的结果。
启动线程并同时保存到列表中
常规版:1
2
3
4
5threadList = []
for i in range(5):
newThread = threading.Thread(target=want)
threadList.append(newThread)
newThread.start()
One-line code:1
threadList = [t.start() or t for i in range(5) for t in [threading.Thread(target=want)]]